In [1]:
%matplotlib inline
from os.path import expanduser, join
from localizer.localizer import Localizer
from localizer import visualization
from scipy.misc import imread
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(color_codes=True)
It is assumed that the saliency-localizer-models
is checkout on the same level as the saliency-localizer
repository.
Depending on your setup you might have to change this path.
In [2]:
loc = Localizer()
loc.load_weights('../saliency-localizer-models/season_2015')
In [3]:
loc.compile()
You have to preprocess the images in the deeplocalizer_data
with the preprocess
tool from deeplocalizer-tagger
.
You can either use the wrapper:
./scripts/generate_all_borders.sh images/season_2015
Or use the preprocess tool:
cd /images/season_2015/cam3/
echo "Cam_3_20150911120716_197902_wb.jpeg" > add_border_images.txt
preprocess add_border_images.txt -o `pwd` --use-hist-eq 1 --use-threshold 1
In [4]:
image_fname = '../deeplocalizer_data/images/season_2015/cam3/Cam_3_20150911120716_197902_wb.jpeg'
In [5]:
saliencies, candidates, rois = loc.detect_tags(image_fname)
In [6]:
fig = visualization.plot_sample_images(rois, saliencies)
In [7]:
plt.figure(figsize=(16, 16))
_ = plt.imshow(visualization.get_roi_overlay(candidates, imread(image_fname) / 255.))